package com.xiaoai.mytest;

import com.mongodb.MongoClient;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import org.junit.Test;

/**
 * @Author
 * @Date 2021-07-25 00:09
 */
public class MyTest {
    public static void main(String[] args) throws InterruptedException {
        boolean flag = true;

        while (flag){
            System.out.println("helle word!");
            Thread.sleep(5000);
        }
    }


    @Test
    public void test(){

    }


    @Test
    public void testRadis1(){


        
    }


    /**
     * 查询打印全部集合
     */
    public static void mongoQueryAll() {
        //1.创建链接
        MongoClient client = new MongoClient("localhost",27017);
        //2.打开数据库test
        MongoDatabase db = client.getDatabase("test");
        //3.获取集合
        MongoCollection<Document> collection = db.getCollection("stu");
        //4.查询获取文档集合
        FindIterable<Document> documents = collection.find();
        //5.循环遍历
        for (Document document : documents) {
            System.out.println(document);
        }
        //6.关闭连接
        client.close();
    }

    @Test
    public void testThread(){
        // 获取cpu核数
        // cpu密集型， io密集型
        System.out.println(Runtime.getRuntime().availableProcessors());
        System.out.println(Runtime.getRuntime().maxMemory());
    }


}
